<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${question.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" href="/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="/css/community.css"/>
    <link rel="stylesheet" href="/editormd/css/editormd.preview.min.css" />
    <script src="/js/jquery.min.js" type="application/javascript"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/moments.js" type="application/javascript"></script>
    <script src="/js/community.js" type="application/javascript"></script>
    <script src="/editormd/editormd.js"></script>
    <script src="/editormd/lib/marked.min.js"></script>
    <script src="/editormd/lib/prettify.min.js"></script>
</head>
<body>
<div th:include="navigition :: nav"></div>
<div class="container-fluid main profile">
    <div class="row">
        <!--左边主要部分-->
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <!--问题正文-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4 class="question-title"><span th:text="${question.title}"></span></h4>
                <span class="text-desc">
                    作者：<span th:text="${question.user.name}"></span> |
                    发布时间：<span th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd H:mm')}"></span> |
                    阅读数：<span th:text="${question.viewCount}"></span>
                </span>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="question-view">
                    <textarea th:text="${question.description}" style="display:none;"> </textarea>
                </div>
                <script type="text/javascript">
                    $(function() {
                        editormd.markdownToHTML("question-view", {
                            emoji:true
                        });
                    });
                </script>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" >
                    <span class="label label-success question-tag" th:each="tag:${question.tag.split(',')}">
                        <span class="glyphicon glyphicon-tags" aria-hidden="true"></span>
                        <span class="label label-success" th:text="${tag}"></span>
                    </span>
                </div>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" >
                    <a th:href="@{'/publish/'+${question.id}}" class="community-menu" th:if="${session.user != null && session.user.id== question.creator}">
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true">编辑</span>
                    </a>
                </div>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            </div>

            <!--回复列表-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <h4><span th:text="${question.commentCount}"></span> 个回复</h4>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comments" th:each="comment:${commentList}">
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-rounded" th:src="${comment.user.avatarUrl}">
                        </a>
                    </div>
                    <div class="media-body">
                        <h5 class="media-heading">
                            <span th:text="${comment.user.name}"></span>
                        </h5>
                        <div th:text="${comment.content}"></div>
                        <div class="menu">
                            <span class="glyphicon glyphicon-thumbs-up icon" aria-hidden="true"> </span>
                            <span th:data-id="${comment.id}" onclick="collapseComments(this)" class="comment-icon">
                            <span class="glyphicon glyphicon-comment" aria-hidden="true" ></span>
                            <span th:text="${comment.commentCount}"></span>
                            </span>
                            <span class="pull-right" th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd')}"></span>
                        </div>
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 collapse sub-comments" th:id="${'comment-'+comment.id}">
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                <input type="text" class="form-control" placeholder="说点什么......" th:id="${'input-'+comment.id}">
                                <button type="button" class="btn btn-success pull-right" onclick="comment(this)" th:data-id="${comment.id}">评论</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            </div>

            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>提交回复</h4>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp">
            <!--回复框-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="comment_section">
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-rounded" th:src="${session.user != null ? session.user.avatarUrl : '/img/default_avatar.png'}">
                        </a>
                    </div>
                    <div class="media-body">
                        <h5 class="media-heading">
                            <span th:text="${session.user != null ? session.user.name : '神秘用户'}"></span>
                        </h5>
                    </div>
                </div>
                <input type="hidden" id="question_id" th:value="${question.id}">
                <textarea class="form-control comment" rows="6" id="comment_content"></textarea>
                <button type="button" class="btn btn-success comment-btn" onclick="post()">回复</button>
            </div>
            </div>
        </div>

        <!--右边部分-->
        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>发起人</h4>
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-circle" th:src="${question.user.avatarUrl}">
                        </a>
                    </div>
                    <div class="media-body">
                        <h5 class="media-heading">
                            <span th:text="${question.user.name}"></span>
                        </h5>
                    </div>
                </div>
            </div>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>在线乞讨</h4>
                <img src="/img/wei-zfb.png" class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                <img src="/img/wei-wx.png" class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
            </div>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>相关问题</h4>
                <ul class="question-releated">
                    <li th:each="releated:${releatedQuestions}">
                        <a th:href="@{'/question/'+ ${releated.id}}" th:text="${releated.title}"></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div th:include="footer ::foot" class="footer"></div>
</body>
</html>